<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ include file="/WEB-INF/jsp/common/taglib.jsp" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
	<meta http-equiv="pragma" content="no-cache" />
	<meta http-equiv="cache-control" content="no-cache" />
	<meta http-equiv="expires" content="0"/>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
	<title>MCU MANAGER</title>
	<%@ include file="/WEB-INF/jsp/common/cssjs2.jsp" %>
	
	<script type="text/javascript">
		$(function(){
			$('.easyui-validatebox').validatebox();
			$('.easyui-validatebox[required]').after("<font color='red'> *</font>");
		});
		
		function inviteCall(){
			if($('.easyui-validatebox').validatebox("isValid")){
				//Callee value maybe ip or endpoint number
				var calleeVal=$("input[name=callee]").val();
				var number="",ip="";
				
				if(/^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$/.test(calleeVal)){
					ip=calleeVal;
				}else{
					number=calleeVal;
				}
				
				var ptcObj={
						"p_number":number,
						"p_ip":ip,
						"p_bandwidth":$("select[name=bandwidth]").val(),
						"p_videoEnabled":$("input[name=enableVideo]").attr("checked")?"true":"false"
				};
				
				$.ajax({
					url:"<c:url value='/app/manage/conf/control/invite'/>",
					type:"POST",
					data:{
						times:new Date().toString(),
						number:"${param.number}",
						participants:$.toJSON([ptcObj])
					},
					success:function(data){
						//alert(data);
						parent.confCtrlViewObj.reloadValues();
						parent.closeWin();
					}
				});	
			}
		}
	</script>
	
	<style type="text/css">
	    html, body {
	        width: 100%;
	        height: 100%;
	        margin: 0px;
	        overflow: hidden;
	    }
	</style>
</head>
<body>
<table border="0" style="width:100%;text-align:left;font-size:12px;margin:20px;" cellpadding="3" cellspacing="0">
	<tr>
		<td>
		<fmt:message key='form.invite.ip'/>
		</td>
		<td>
		<input type="text" name="callee" class="easyui-validatebox" required="true">
		</td>
	</tr>
	<tr>
		<td>
		<fmt:message key='form.invite.video'/>
		</td>
		<td>
		<input type="checkbox" name="enableVideo" checked="checked"><fmt:message key="form.common.enable"/>
		</td>
	</tr>
	<tr>
		<td>
		<fmt:message key='form.invite.bandwidth'/>
		</td>
		<td>
		<select name="bandwidth">
			<option>128</option>
			<option>192</option>
			<option>256</option>
			<option>320</option>
			<option selected>384</option>
			<option>448</option>
			<option>512</option>
			<option>640</option>
			<option>768</option>
			<option>1024</option>
			<option>1536</option>
			<option>1920</option>
			<option>2048</option>
			<option>2560</option>
			<option>3072</option>
			<option>3584</option>
			<option>4096</option>
		</select>
		</td>
	</tr>
	<tr>
		<td colspan="2">
		<button onclick="inviteCall();" class="mybtn"><fmt:message key='btn.ok'/></button>
		<button onclick="parent.closeWin();" class="mybtn"><fmt:message key='btn.cancel'/></button>
		</td>
	</tr>
</table>
</body>
</html>